package com.ny.demo509;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test {
    public static void main(String[] args) throws IOException {

// 需求：获取1.txt的内容
        FileInputStream fileInputStream = new FileInputStream("1.txt");
//      存储文件的数据
        byte[] buffer = new byte[1024];
//      等于-1代表，没有数据
//        给字符添加长度，append
        StringBuilder content = new StringBuilder();
        int bytesRead;
        while((bytesRead = fileInputStream.read(buffer))!=-1){
            content.append(new String(buffer,0,bytesRead));
        }
        System.out.println(content.toString());
      
    }
}
